<h1>姓名</h1>
<input type="text" class="textClass">
<input type="button" class="btnClass" value="點擊">
<input type="button" class="btnCall" value="呼叫">
const btn = document.querySelector('.btnClass');
const call = document.querySelector('.btnCall');
function saveName(e){
const str = document.querySelector('.textClass').value;
localStorage.setItem('myName', str);
}
btn.addEventListener('click', saveName);
call.addEventListener('click', function(){
const str = localStorage.getItem('myName');
alert('姓名:'+str);
})
今天就到這邊結束了。